Fix WikiPage::prepareContentForEdit's default format handling
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 13 Dec 2013 17:15:39 +0000 (12:15 -0500)
committerOri.livneh <ori@wikimedia.org>
Fri, 13 Dec 2013 20:10:22 +0000 (20:10 +0000)
If some caller passes null for the $serialization_format parameter,
they're going to break the in-memory caching of the prepared edit even
though it's likely that the format being used is the same as the format
being used by everything else.

It seems sensible to cache null as the default format for the content
object to avoid this.

Bug: 57026
Change-Id: I4ddcf6e388636e6a6397b664b8683ad774a09a04

includes/WikiPage.php

index 7afc65c..0d987aa 100644 (file)
@@ -2017,6 +2017,11 @@ class WikiPage implements Page, IDBAccessObject {
                $user = is_null( $user ) ? $wgUser : $user;
                //XXX: check $user->getId() here???
 
+               // Use a sane default for $serialization_format, see bug 57026
+               if ( $serialization_format === null ) {
+                       $serialization_format = $content->getContentHandler()->getDefaultFormat();
+               }
+
                if ( $this->mPreparedEdit
                        && $this->mPreparedEdit->newContent
                        && $this->mPreparedEdit->newContent->equals( $content )